CREATE TABLE [CMS_ACLItem] (
		[ACLItemID]                [int] IDENTITY(1, 1) NOT NULL,
		[ACLID]                    [int] NOT NULL,
		[UserID]                   [int] NULL,
		[RoleID]                   [int] NULL,
		[Allowed]                  [int] NOT NULL,
		[Denied]                   [int] NOT NULL,
		[LastModified]             [datetime] NOT NULL,
		[LastModifiedByUserID]     [int] NULL
) 
ALTER TABLE [CMS_ACLItem]
	ADD
	CONSTRAINT [PK_CMS_ACLItem]
	PRIMARY KEY
	CLUSTERED
	([ACLItemID])
	
	
ALTER TABLE [CMS_ACLItem]
	ADD
	CONSTRAINT [DF__CMS_ACLIt__Allow__0EA330E9]
	DEFAULT ((0)) FOR [Allowed]
ALTER TABLE [CMS_ACLItem]
	ADD
	CONSTRAINT [DF__CMS_ACLIt__Denie__0F975522]
	DEFAULT ((0)) FOR [Denied]
CREATE NONCLUSTERED INDEX [IX_CMS_ACLItem_ACLID]
	ON [CMS_ACLItem] ([ACLID])
	
CREATE NONCLUSTERED INDEX [IX_CMS_ACLItem_LastModifiedByUserID]
	ON [CMS_ACLItem] ([LastModifiedByUserID])
	
CREATE NONCLUSTERED INDEX [IX_CMS_ACLItem_RoleID]
	ON [CMS_ACLItem] ([RoleID])
	
CREATE NONCLUSTERED INDEX [IX_CMS_ACLItem_UserID]
	ON [CMS_ACLItem] ([UserID])
	
ALTER TABLE [CMS_ACLItem]
	WITH CHECK
	ADD CONSTRAINT [FK_CMS_ACLItem_ACLID_CMS_ACL]
	FOREIGN KEY ([ACLID]) REFERENCES [CMS_ACL] ([ACLID])
ALTER TABLE [CMS_ACLItem]
	CHECK CONSTRAINT [FK_CMS_ACLItem_ACLID_CMS_ACL]
ALTER TABLE [CMS_ACLItem]
	WITH CHECK
	ADD CONSTRAINT [FK_CMS_ACLItem_LastModifiedByUserID_CMS_User]
	FOREIGN KEY ([LastModifiedByUserID]) REFERENCES [CMS_User] ([UserID])
ALTER TABLE [CMS_ACLItem]
	CHECK CONSTRAINT [FK_CMS_ACLItem_LastModifiedByUserID_CMS_User]
ALTER TABLE [CMS_ACLItem]
	WITH CHECK
	ADD CONSTRAINT [FK_CMS_ACLItem_RoleID_CMS_Role]
	FOREIGN KEY ([RoleID]) REFERENCES [CMS_Role] ([RoleID])
ALTER TABLE [CMS_ACLItem]
	CHECK CONSTRAINT [FK_CMS_ACLItem_RoleID_CMS_Role]
ALTER TABLE [CMS_ACLItem]
	WITH CHECK
	ADD CONSTRAINT [FK_CMS_ACLItem_UserID_CMS_User]
	FOREIGN KEY ([UserID]) REFERENCES [CMS_User] ([UserID])
ALTER TABLE [CMS_ACLItem]
	CHECK CONSTRAINT [FK_CMS_ACLItem_UserID_CMS_User]
